<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>canvas</title>
  <style>
    #chart {
      /* width: 1000px;
      height: 400px; */
      background-color: gray;
    }
  </style>
</head>

<body>
  <!-- 只能在标签上指定宽高 -->
  <canvas id="chart" width="1000" height="400"></canvas>

  <script>
    const canvas = document.getElementById('chart')
    const ctx = canvas.getContext('2d')

    // 开始绘画
    // fillRect(x, y, width, height)
    // strokeRect(x, y, width, height)
    // (x, y) 是左上角点的坐标
    // ctx.fillStyle = 'pink'
    // ctx.fillRect(100, 100, 400, 200)
    // ctx.strokeRect(100, 100, 400, 200)
    ctx.strokeRect(100, 100, 200, 200)
  </script>
</body>

</html>